<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>课程信息</title>
  <style>
    #tab{

    }
    #tab td {
        text-align: center;
    }
  </style>
    <script>
        function gotoPage(v){
            //window.location.href="list?pageNo="+v.value;
            window.location.href="/subject/list?pageNo="+v.value+"&name=[[${name?:''}]]";
        }
        function gotoPage2(v,event){
            console.log("keycode,",event.keyCode);

            if(event.keyCode==13){
                window.location.href="/subject/list?pageNo="+v.value+"&name=[[${name?:''}]]";
                return true;
            }
            return false;
        }
    </script>
</head>
<body>
   <h1>课程信息</h1>
   <p>
       <form action="/subject/list">
         <input type="search" name="name" th:value="${name}"/>
         <input type="submit" value="搜索"/>
       <a href="/subject/toAdd">添加</a>
       </form>
   </p>
  <table id="tab" width="85%" border="1" cellpadding="0" cellspacing="0">
     <tr>
       <th>编号</th>
       <th>课程</th>
       <th>学时</th>
       <th>年级号</th>
       <th>操作</th>
     </tr>
    <tr th:each="s:${p.data}">
      <td th:text="${s.id}"></td>
      <td th:text="${s.subjectname}"></td>
      <td th:text="${s.classhour}"></td>
      <td th:text="${s.gradeid}"></td>
      <td>
          <a th:href="@{'/subject/toUpdate?id='+${s.id}}">修改</a>
          <a onclick="return window.confirm('真的要删除？')" th:href="@{'/subject/del?id='+${s.id}}">删除</a>
          <a th:href="@{'/subject/toDetail?id='+${s.id}}">详情</a>
      </td>
    </tr>
  </table>
<p>
    <a th:href="@{'/subject/list?pageNo=1'+'&name='+${name?:''}}">第一页</a>
    <a th:if="${p.pageNo>1}" th:href="@{'/subject/list?pageNo=' + ${p.pageNo-1}+'&name='+${name?:''}}">上一页</a>
    <input type="number" th:value="${p.pageNo}" style="width: 25px" name="pageNo" min="1" th:max="${p.pageTotal}" onkeydown="gotoPage2(this,event)" onblur="gotoPage(this)"/>
    /<span th:text="${p.pageTotal}"></span>
    <a th:if="${p.pageNo<p.pageTotal}" th:href="@{'/subject/list?pageNo=' + ${p.pageNo+1}+'&name='+${name?:''}}">下一页</a>
    <a th:href="@{'/subject/list?pageNo=' + ${p.pageTotal}+'&name='+${name?:''}}">最后一页</a>

</p>
</body>
</html>